#include "Vector2.h"
#include <math.h>

Vector2::Vector2()
{
	Set(Vector2::Zero().X, Vector2::Zero().Y);
}

Vector2::Vector2(float x, float y)
{
	Set(x, y);
}

Vector2::Vector2(float value)
{
	Set(value, value);
}


void Vector2::Set(float x, float y)
{
	 Vector2::X = x; 
	 Vector2::Y = y;

}


Vector2 Vector2::operator +(Vector2 v1)
{
	Vector2::X += v1.X;
	Vector2::Y += v1.Y;


	return Vector2(Vector2::X, Vector2::Y);
}

Vector2 Vector2::operator -(Vector2 v1)
{
	Vector2::X -= v1.X;
	Vector2::Y -= v1.Y;


	return Vector2(Vector2::X, Vector2::Y);
}

Vector2 Vector2::operator *(Vector2 v1)
{
	Vector2::X *= v1.X;
	Vector2::Y *= v1.Y;

	return Vector2(Vector2::X, Vector2::Y);
}

Vector2 Vector2::operator *(float f)
{
	Vector2::X *= f;
	Vector2::Y *= f;

	return Vector2(Vector2::X, Vector2::Y);
}

bool Vector2::operator ==(const Vector2 &v)
{
	return Vector2::X == v.X && Vector2::Y == v.Y;
}

void Vector2::Add(Vector2 v)
{
	Vector2::X += v.X;
	Vector2::Y += v.Y;
}

void Vector2::Subtract(Vector2 v)
{
	Vector2::X -= v.X;
	Vector2::Y -= v.Y;
}

float Vector2::Distance(Vector2 v)
{
	float dx = v.X - Vector2::X;
	float dy = v.Y - Vector2::Y;

	return sqrt(pow(dx,2) + pow(dy,2));
}